package cn.com.haopy.yue.ai.wx.web;

import cn.com.haopy.yue.ai.core.utils.ResponseUtil;
import cn.com.haopy.yue.ai.db.service.hos.AIRiskAdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 广告服务
 */
@RestController
@RequestMapping("/haopyYueAi/ad")
@Validated
@Slf4j
@RequiredArgsConstructor
@Api(tags = "广告服务")
public class WxAdController {
    @NonNull
    private AIRiskAdService adService;

    /**
     * 商城介绍信息
     *
     * @ret 商城介绍信息
     */
    @GetMapping("/adList")
    @ApiOperation("根据类型获取广告")
    public Object adList(@RequestParam @ApiParam("广告位置") Short position) {
        return ResponseUtil.ok(adService.listByPosition(position));
    }

    /**
     * 商城介绍信息
     *
     * @ret 商城介绍信息
     */
    @GetMapping("/adDetail")
    @ApiOperation("广告详情")
    public Object adDetail(@RequestParam @ApiParam("广告ID") Integer id) {
        return ResponseUtil.ok(adService.getById(id));
    }
}